package com.tedu.api;

import org.junit.Test;

public class 字符串作业 {
    //1.输出字符串"HelloJava"的字符串长度
    @Test
    public void testLength(){
        String str="HelloJava";
        System.out.println(str.length());
    }
    //2.输出"HelloJava"中o的位置
    @Test
    public void testIndexOf() {
        String str = "HelloJava";
        //返回值：下标位
        int index = str.indexOf("o");
        System.out.println("o的位置:" + index);
    }
    //3.输出"HelloJava"中下标为5处开始第一次出现以"o"的位置
    @Test
    public void testIndexOf6(){
        String str="HelloJava";
       int index=str.indexOf("o");
        index=str.indexOf("o",5);
        System.out.println(index);
    }


    //4.截取"HelloJava"中"Hello"并输出
    @Test
    public void testSubString2() {
        String url ="HelloJava";
        url = url.substring(0,5);
        System.out.println("HelloJava中:"+url);
    }
    //5.截取"HelloJava"中"Java"并输出
    @Test
    public void testSubString0() {
        String url = "HelloJava";
        url = url.substring(5,9);
        System.out.println("HelloJava中:"+url);
    }
    //6.将字符串" Hello "中两边的空白去掉后输出
    @Test
    public void testTrim1(){
        String str=" Hello ";
        str=str.trim().toLowerCase();
        System.out.println("去掉空格："+str);

    }
    //7.输出"HelloJava"中第6个字符"J"
    @Test
    public void testSubString() {
        String url = "HelloJava";
        url = url.substring(5,6);
        System.out.println("HelloJava第6个字符:"+url);
    }
    //8.将"HelloJava"转换为小写，然后转换为大写
    @Test
    public void testTrim(){
        String str="HelloJava";
        str=str.trim().toLowerCase();
        System.out.println("小写："+str);
        str=str.trim().toUpperCase();
        System.out.println("大写："+str);

    }
}
